/*
 * MisMain.java
 *
 * Created on 27 de noviembre de 2006, 03:04 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package pruebas;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.swing.JFrame;

public class MisMain {

    public static void main(String[] arg) throws Exception {
        int tipo = 4;
        switch (tipo) {
            case 3://return "java.lang.Double";
            case 8://return "java.lang.Double";
            case 2://return "java.lang.Double";
            case 7://return "java.lang.Double";
                System.out.println("Double");
                //break;
            case 4://return "java.lang.Integer";
            case -5://return "java.lang.Integer";
                System.out.println("Integer");
                //break;
            case 6://return "java.lang.Float";
                System.out.println("Float");
                break;
            case 1://return "java.lang.String";
            case 12://return "java.lang.String";
            case 2005://return "java.lang.String";
                System.out.println("String");
                break;
            case 91://return "java.util.Date";
            case 92://return "java.util.Date";
            case 93://return "java.util.Date";
                System.out.println("Date");
                break;
            case 16://return "java.util.Boolean";
                System.out.println("Boolean");
                break;
            //                public final static int BIT 		=  -7;
            //                public final static int TINYINT 	=  -6;
            //                public final static int SMALLINT	=   5;
            //                public final static int INTEGER 	=   4;
            //                public final static int BIGINT 		=  -5;
            //                public final static int FLOAT 		=   6;
            //                public final static int REAL 		=   7;
            //                public final static int DOUBLE 		=   8;
            //                public final static int NUMERIC 	=   2;
            //                public final static int DECIMAL		=   3;
            //                public final static int CHAR		=   1;
            //                public final static int VARCHAR 	=  12;
            //                public final static int LONGVARCHAR 	=  -1;
            //                public final static int DATE 		=  91;
            //                public final static int TIME 		=  92;
            //                public final static int TIMESTAMP 	=  93;
            //                public final static int BINARY		=  -2;
            //                public final static int VARBINARY 	=  -3;
            //                public final static int LONGVARBINARY 	=  -4;
            //                public final static int NULL		=   0;
            //                public final static int OTHER		= 1111;
            //                public final static int JAVA_OBJECT         = 2000;
            //                public final static int DISTINCT            = 2001;
            //                public final static int STRUCT              = 2002;
            //                public final static int ARRAY               = 2003;
            //                public final static int BLOB                = 2004;
            //                public final static int CLOB                = 2005;
            //                public final static int REF                 = 2006;
            //                public final static int DATALINK = 70;
            //                public final static int BOOLEAN = 16;
        }

        /*Class.forName("oracle.jdbc.driver.OracleDriver");
         Class.forName("net.sourceforge.jtds.jdbc.Driver");
        
         Connection connection = DriverManager.getConnection(
         "jdbc:jtds:sqlserver://localhost:1433/sevinpro"
         //"jdbc:oracle:thin:@200.1.82.6:1621:metricap"
         , "sa", "");
         connection.close();
         String query = ("SELECT A.CODORIG AS CODORIG, A.CODPORTAF AS CODPORTAF, D.CODIGOTIT AS CODIGOTIT, T .NOMBRETIT AS ESPECIE, M.NOMBRE AS MONEDA, PO.NOMBRE AS PORTAFOLIO, E.NOMBRE AS EMISOR, E.CODTERCERO AS CODTERCERO , D.FECVENCDOC AS FECHAVENCIMIENTO, D.FECCPRADOC AS FECHACOMPRA, ISNULL((SELECT SUM(SALDOCAP) FROM VALORAC WHERE CODORIG = A.CODORIG AND CODPORTAF = A.CODPORTAF AND REVERSADO = 'N' AND FECHAVAL = ?),0) AS VALORNOMINAL2, D.NUMERODOC, ISNULL((SELECT SUM(VALORMDO * VALMONCALC) FROM VALORAC WHERE CODORIG = A. CODORIG AND CODPORTAF = A. CODPORTAF AND REVERSADO = 'N' AND FECHAVAL = ? ),0) AS VALORMDO1, ISNULL (( SELECT SUM(VALORMDO*VALMONCALC) FROM VALORAC WHERE CODORIG = A. CODORIG AND CODPORTAF = A.CODPORTAF AND REVERSADO = 'N' AND FECHAVAL = ?), 0) AS VALORMDO2, ISNULL((SELECT SUM(CP.COMPRAS) AS COMPRAS FROM ( SELECT SUM(P.PRECCPRDOC * N.VALMONEDA) AS COMPRAS FROM PARTIDAS P INNER JOIN NEGOCIOS N ON P.CODIGODOC = N.CODIGODOC WHERE N.CODORIG = A.CODORIG AND N.CODPORTAF=A.CODPORTAF AND (P. ACTIVO = 'S' OR P.ACTIVO <> 'S') AND N.REVERSADO = 'N' AND N.OPERACION IN (6110000,6120000,6310000,6310001,6410000) AND FECCPRADOC>? AND FECCPRADOC <= ? UNION SELECT VALORMDO*VALMONCALC AS COMPRAS FROM TRASLADOSPORT T INNER JOIN PARTIDAS P ON T.CODORIG = P.CODORIG AND P.CODIGODOC = T.CODIGODOC WHERE T.PORTAFDESTINO = A.CODPORTAF AND P.CODIGODOC = A.CODIGODOC AND FECHA<= ? AND FECHA>? ) CP),0) AS COMPRAS, ISNULL((SELECT SUM(VT.VENTAS) AS VENTAS FROM ( SELECT SUM(VALNEG*VALMONEDA) AS VENTAS FROM NEGOCIOS WHERE OPERACION IN (6210000,6330000,6330001,6430000) AND CODORIG = A. CODORIG AND CODPORTAF = A.CODPORTAF AND REVERSADO = 'N' AND FECONFIRM> ? AND FECONFIRM<= ? UNION SELECT VALORMDO*VALMONCALC AS VENTAS FROM TRASLADOSPORT T INNER JOIN PARTIDAS P ON T.CODORIG = P.CODORIG AND P.CODIGODOC = T.CODIGODOC WHERE PORTAFORIGEN = A.CODPORTAF AND P.CODIGODOC = A.CODIGODOC AND FECHA<= ? AND FECHA>? ) VT),0) AS VENTAS, ISNULL((SELECT SUM(VALOR* VALMONEDA) AS RECUPERACIONES FROM INVPEND WHERE CONCEPTO NOT IN ('NEG','VAL') AND FECHA > ? AND FECHA<= ? AND REVERSADO = 'N' AND CODORIG = A.CODORIG AND CODPORTAF = A. CODPORTAF ),0) AS RECUPERACIONES, ISNULL((SELECT SUM((VALNEG-VALORMDO)* VALMONEDA) AS UTILIDAD FROM NEGOCIOS WHERE OPERACION IN (6210000,6330000,6330001,6430000) AND CODORIG = A.CODORIG AND CODPORTAF = A. CODPORTAF AND REVERSADO = 'N' AND FECONFIRM> ? AND FECONFIRM<= ?) ,0) AS UTILVTA, ISNULL((SELECT AVG(TASAVAL) AS TIR FROM VALORAC V WHERE V.FECHAVAL = ? AND V.REVERSADO = 'N' AND V.CODORIG = A.CODORIG AND V.CODPORTAF = A.CODPORTAF),0) AS TIRINICIAL, ISNULL((SELECT AVG(TASAVAL) AS TIR FROM VALORAC V WHERE V.FECHAVAL = ? AND V.REVERSADO = 'N' AND V.CODORIG = A.CODORIG AND V.CODPORTAF = A. CODPORTAF),0) AS TIRFINAL, CASE A.CLASIFIC WHEN 'V' THEN (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBVENC and cp.gruportaf = po.grupcont),0)) WHEN 'D' THEN (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBDISP and cp.gruportaf = po.grupcont),0)) ELSE (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBNEG and cp.gruportaf = po.grupcont),0)) END AS CUENTAPUC , T.CODMONEDA AS CODMONEDA, T.CODSIST1, T.CODSIST2, T.CODSIST3, ISNULL((SELECT SUM(SALDOCAP) FROM VALORAC WHERE CODORIG = A.CODORIG AND CODPORTAF = A.CODPORTAF AND REVERSADO = 'N' AND FECHAVAL =?),0) AS VALORNOMINAL1 FROM (VALORAC A INNER JOIN (DOCUMENT D INNER JOIN (TITULOS T INNER JOIN MONEDAS M ON T .CODMONEDA = M.CODIGO LEFT JOIN TERCEROS E ON T .EMISOR = E.CODTERCERO) ON D.CODIGOTIT = T .CODIGOTIT ) ON A.CODORIG = D.CODORIG) INNER JOIN PORTAFOL PO ON A.CODPORTAF = PO.CODPORTAF INNER JOIN PORTGRUP PG ON A.CODPORTAF = PG.CODPORTAF WHERE (A.FECHAVAL >= ?) AND (A.FECHAVAL <= ?) AND PG.CODGRUPO = ? AND A.GARANTIA = 'N' AND A.REVERSADO = 'N' UNION SELECT A.CODORIG AS CODORIG, NC.CODPORTAF AS CODPORTAF, D.CODIGOTIT AS CODIGOTIT, T .NOMBRETIT AS ESPECIE, M.NOMBRE AS MONEDA, PO.NOMBRE AS PORTAFOLIO, E.NOMBRE AS EMISOR, E.CODTERCERO AS CODTERCERO, D . FECVENCDOC AS FECHAVENCIMIENTO, D.FECCPRADOC AS FECHACOMPRA, SUM(A.VALORNOM) AS VALORNOMINAL, D.NUMERODOC, 0 AS VALORMDO1, 0 AS VALORMDO2, SUM(A.PRECCPRDOC * NC.VALMONEDA) AS COMPRAS, SUM(A. PRECVTADOC*NV.VALMONEDA) AS VENTAS , 0 AS RECUPERACIONES, SUM((A.PRECVTADOC*NV.VALMONEDA)-(A.PRECCPRDOC * NC.VALMONEDA)) AS UTILVTA, 0 AS TIRINICIAL, 0 AS TIRFINAL, CASE NC.CLASIFIC WHEN 'V' THEN (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBVENC and cp.gruportaf = po.grupcont),0)) WHEN 'D' THEN (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBDISP and cp.gruportaf = po.grupcont),0)) ELSE (ISNULL(( SELECT CP.CODIGOPUC FROM COMBIPUC CP WHERE CODCOLUM=2 AND CP.CODFAM=T.COMBNEG and cp.gruportaf = po.grupcont),0)) END AS CUENTAPUC , T.CODMONEDA AS CODMONEDA, T.CODSIST1, T.CODSIST2, T.CODSIST3, A.VALORNOM FROM PARTIDAS A INNER JOIN DOCUMENT D ON A.CODORIG = D.CODORIG INNER JOIN TITULOS T ON D.CODIGOTIT = T .CODIGOTIT LEFT JOIN MONEDAS M ON T .CODMONEDA = M.CODIGO INNER JOIN TERCEROS E ON T .EMISOR = E.CODTERCERO LEFT JOIN NEGOCIOS NC ON NC.CODORIG=A.CODORIG AND NC.OPERACION IN (6110000,6120000,6310000,6310001,6410000) LEFT JOIN NEGOCIOS NV ON NV.CODIGODOC=A.CODIGODOC AND NV.OPERACION IN (6210000,6330000,6330001,6430000) LEFT JOIN PORTAFOL PO ON NC.CODPORTAF = PO.CODPORTAF LEFT JOIN PORTGRUP PG ON NC.CODPORTAF = PG.CODPORTAF AND PG.CODGRUPO = ? WHERE A.ESTADO = 2 AND (A.FECCPRADOC=A.FECHVTADOC) AND (A.FECCPRADOC > ?) AND (A.FECCPRADOC <= ?) AND A.GARANTIA = 'N' AND A.REVERSADO = 'N' GROUP BY A.CODORIG , NC.CODPORTAF, D.CODIGOTIT , T .NOMBRETIT, M.NOMBRE , PO.NOMBRE , E.NOMBRE , E.CODTERCERO, D .FECVENCDOC, D.FECCPRADOC , D.NUMERODOC, T.COMBNEG, T.CODMONEDA, T.CODSIST1, T.CODSIST2, T.CODSIST3, NC.CLASIFIC, T.COMBDISP, T.COMBVENC, A.VALORNOM, po.grupcont ORDER BY CODPORTAF, MONEDA, CODIGOTIT, CODORIG");

         PreparedStatement  ps = connection.prepareStatement(query);
        
         ps.executeQuery();*/

        /*String DATA_BASE = connection.getMetaData().getDatabaseProductName().trim();
         String user = connection.getCatalog();
         String Mdw="METRICADW";
         String Mdb="METRICADB";
         if (user == null && DATA_BASE.trim().equals("Oracle")) {
         user = connection.getMetaData().getUserName();
         }

         if (user.equalsIgnoreCase("METRICADW")) {
         Mdw = connection.getCatalog();
         if (Mdw == null && DATA_BASE.trim().equals("Oracle")) {
         Mdw = connection.getMetaData().getUserName();
         }
         } else if (user.equalsIgnoreCase("METRICADB")) {
         Mdb = connection.getCatalog();
         if (Mdb == null && DATA_BASE.trim().equals("Oracle")) {
         Mdb = connection.getMetaData().getUserName();
         }
         }

         query = query.toUpperCase();
         //se hace el cambio de los nombres quemados de metricadb y metricadw

         String VACIO = "";
         if (DATA_BASE.equals("Oracle")) {
         VACIO = ".";
         query = query.replace("ISNULL", "NVL");
         }

         query = query.replace("METRICADB" + VACIO, Mdb);
         query = query.replace("METRICADW" + VACIO, Mdw);
         System.out.println("query : "+query);*/
    }
}
